package com.ruoyi.project.xcx.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.xcx.domain.XcxClass;
import com.ruoyi.project.xcx.service.IXcxClassService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 小程序-分类图标管理Controller
 * 
 * @author ruoyi
 * @date 2020-06-10
 */
@RestController
@RequestMapping("/xcx/class")
public class XcxClassController extends BaseController
{
    @Autowired
    private IXcxClassService xcxClassService;

    /**
     * 查询小程序-分类图标管理列表
     */
    @PreAuthorize("@ss.hasPermi('xcx:class:list')")
    @GetMapping("/list")
    public TableDataInfo list(XcxClass xcxClass)
    {
        startPage();
        List<XcxClass> list = xcxClassService.selectXcxClassList(xcxClass);
        return getDataTable(list);
    }

    /**
     * 导出小程序-分类图标管理列表
     */
    @PreAuthorize("@ss.hasPermi('xcx:class:export')")
    @Log(title = "小程序-分类图标管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(XcxClass xcxClass)
    {
        List<XcxClass> list = xcxClassService.selectXcxClassList(xcxClass);
        ExcelUtil<XcxClass> util = new ExcelUtil<XcxClass>(XcxClass.class);
        return util.exportExcel(list, "class");
    }

    /**
     * 获取小程序-分类图标管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('xcx:class:query')")
    @GetMapping(value = "/{cid}")
    public AjaxResult getInfo(@PathVariable("cid") Long cid)
    {
        return AjaxResult.success(xcxClassService.selectXcxClassById(cid));
    }

    /**
     * 新增小程序-分类图标管理
     */
    @PreAuthorize("@ss.hasPermi('xcx:class:add')")
    @Log(title = "小程序-分类图标管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XcxClass xcxClass)
    {
        return toAjax(xcxClassService.insertXcxClass(xcxClass));
    }

    /**
     * 修改小程序-分类图标管理
     */
    @PreAuthorize("@ss.hasPermi('xcx:class:edit')")
    @Log(title = "小程序-分类图标管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XcxClass xcxClass)
    {
        return toAjax(xcxClassService.updateXcxClass(xcxClass));
    }

    /**
     * 删除小程序-分类图标管理
     */
    @PreAuthorize("@ss.hasPermi('xcx:class:remove')")
    @Log(title = "小程序-分类图标管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cids}")
    public AjaxResult remove(@PathVariable Long[] cids)
    {
        return toAjax(xcxClassService.deleteXcxClassByIds(cids));
    }
}
